const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('stu', {
    stuid: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      references: {
        model: 'user',
        key: 'id'
      }
    },
    stunum: {
      type: DataTypes.STRING(12),
      allowNull: false
    },
    classid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "每个用户只能归属于一个行政班。"
    }
  }, {
    sequelize,
    tableName: 'stu',
    hasTrigger: true,
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "stuid" },
        ]
      },
    ]
  });
};
